const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: './src/index.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'my-first-webpack.bundle.js',
  },
  module: {
    rules: [
      {
        test: /\.css$/i,
        use: ["style-loader", "css-loader"],
      },
      {
        test: /\.s[ac]ss$/i,
        use: [
          // 将 JS 字符串生成为 style 节点
          'style-loader',
          // 将 CSS 转化成 CommonJS 模块
          'css-loader',
          // 将 Sass 编译成 CSS
          'sass-loader',
        ],
      },
    ],
    
  },
  plugins: [new HtmlWebpackPlugin()],
};

let mock=require('mockjs')
let data=mock.mock=({
    "list|4":[{
        "img":"@image(100x100,@color)",
        "title":"@ctitle"
    }]
})
// 抛出
module.exports = {
   devServer: {
    open: true,
    hot: true,
    port: 8080,
    before(app){
        app.get('/list', (req, res) => {
            res.send(data.list)
            // 发送
        })
    }
}, 
}
